package tree;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class sumOfLeftLeaves {
    public int result = 0;
    public int sumOfLeftLeaves(TreeNode root) {
        if (root == null || root.left == null && root.right == null){
            return result;
        }
        preorder(root);
        return result;
    }
    public void preorder(TreeNode root){
        if (root == null){
            return;
        }
        preorder(root.left);
        preorder(root.right);
        if (root.left != null && root.left.left == null && root.left.right == null){
            result += root.left.val;
        }
    }
}
